package com.findme.securitydb.utils.returnTool;

/**
 * @Description 返回封装
 * @Author find me
 * @Createtime 2020/2/20 23:20
 * @ClassName ResTool
 */
//@Data
//@AllArgsConstructor
//@NoArgsConstructor
public class ResTool<T> {

    //-2为系统错误
    // -1为操作失败
    private int code = 200;

    private String msg = "";
    private String error = "";
    private T data;

    public static ResTool ok = new ResTool();
    public static ResTool fail = new ResTool().code(-1);


    public static ResTool build() {
        return new ResTool();
    }


    public static <T> ResTool build(T data) {
        return new ResTool().data(data);
    }


    public ResTool code(int code) {
        this.code = code;
        return this;
    }

    public ResTool data(T data) {
        this.data = data;
        return this;
    }

    public ResTool msg(String msg) {
        this.msg = msg;
        return this;
    }

    public ResTool error(String error) {
        this.error = error;
        return this;
    }


    public int getCode() {
        return code;
    }

    public T getData() {
        return data;
    }

    public String getMsg() {
        return msg;
    }

    public String getError() {
        return error;
    }

    public static ResTool getOk() {
        return ok;
    }

    public static ResTool getFail() {
        return fail;
    }
}

